package com.nightsoul.groovy

import groovy.xml.MarkupBuilderimport groovy.util.NodeBuilderimport groovy.lang.GroovyShellimport java.lang.System
public class BuilderTest{

	public static void main(def args){
		testNodeBuilder();
		
		new Date().identity {
			println "${date}.$year.$month"
		}
		
	}
	
	public static void testMarkupBuilder() {
		def builder = new MarkupBuilder();
		builder.numbers {
			description 'Squares and factors of 10..15'
			
			for(i in 10..15) {
				number(value:i, square:i*i) {
					for(j in 2..<i) {
						if(i%j==0) {
							factor(value:j)
						}
					}
				}
			}
		}
		
		builder.print(System.out);
	}
	
	public static void testNodeBuilder() {
		def builder = new NodeBuilder();
		def ulcDate = new Date(107, 0, 1);
		def novices = builder.invoices {
			invoice(date:ulcDate) {
				item(count:5) {
					product(name:"ULC", dollar:1499)
				}
				item(count:1) {
					product(name:"Visual Editor", dollar:499)
				}
			}
			
			invoice(date:new Date(106, 1, 2)
			) {
				item(count:4) {
					product(name:"Visual Editor", dollar:499)
				}
			}
		};
		
		println novices;
		println novices.getClass();
	}
}
